package com.kantboot.api.phone.service.impl;

import com.kantboot.api.phone.domain.ApiPhoneBelongTo;
import com.kantboot.api.phone.repository.ApiPhoneBelongToRepository;
import com.kantboot.api.phone.service.IApiPhoneBelongToService;
import com.kantboot.util.common.exception.BaseException;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class ApiPhoneBelongToServiceImpl implements IApiPhoneBelongToService {

    @Resource
    private ApiPhoneBelongToRepository repository;

    /**
     * 根据手机号获取归属地
     */
    @Override
    public ApiPhoneBelongTo getByPhone(String phone) {
        ApiPhoneBelongTo byPhone = repository.findByPhone(phone);
        if (byPhone == null) {
            throw BaseException.of("unknown", "未知归属地");
        }
        return byPhone;
    }

}
